package com.ms.education.statistics.jobs;

import cn.hutool.core.date.DateUtil;
import com.dangdang.ddframe.job.api.ShardingContext;
import com.dangdang.ddframe.job.api.simple.SimpleJob;
import com.ms.education.ServerUtils;
import com.ms.education.statistics.service.StatisticsDailyService;
import lombok.extern.slf4j.Slf4j;

import java.util.concurrent.TimeUnit;

/**
 * <p>Project:我的代码-MySimpleJob
 * <p>Powered by ms on 2023-02-11 19:09:34
 *
 * @author ms
 * @version 1.0
 * @since 1.8
 */
@Slf4j
public class StatisticDailyJob implements SimpleJob {

    private StatisticsDailyService statisticsDailyService;


    public StatisticDailyJob(StatisticsDailyService statisticsDailyService) {
        this.statisticsDailyService = statisticsDailyService;
    }

    @Override
    public void execute(ShardingContext shardingContext) {
        log.info("{}:日常统计任务开始，时间：{}",ServerUtils.SERVER_IP_PORT,DateUtil.now());
        statisticsDailyService.createDailyDate(DateUtil.yesterday().toString("yyyy-MM-dd"));
        log.info("{}:日常统计结束，统计包括【注册人数，登录人数，视频破放量，课程新增量】",ServerUtils.SERVER_IP_PORT);
    }
}
